package com.cn.hotel.dao.Impl;

import com.cn.hotel.dao.ICompanyContactDao;
import com.cn.hotel.model.CompanyContactModel;
import com.cn.hotel.model.CompanyModel;
import com.cn.hotel.util.GetSqlSession;
import com.cn.hotel.util.JDBC;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class CompanyContactImpl implements ICompanyContactDao {
    @Override
    public List<CompanyContactModel> findAll(CompanyContactModel companyContactModel) {
        return GetSqlSession.getSqlSession().selectList("com.cn.hotel.dao.ICompanyContactDao.findAll",companyContactModel);
    }

    /**
     * 通过id查询信息给编辑页面赋值
     * @param temp
     * @return
     */
    @Override
    public CompanyContactModel findById(Integer temp) {
        return GetSqlSession.getSqlSession().selectOne("com.cn.hotel.dao.ICompanyContactDao.findById",temp);
    }

    @Override
    public int edit(CompanyContactModel companyModel) {
        return GetSqlSession.getSqlSession().update("com.cn.hotel.dao.ICompanyContactDao.edit",companyModel);
    }

    @Override
    public int add(CompanyContactModel companyModel) {
        return GetSqlSession.getSqlSession().insert("com.cn.hotel.dao.ICompanyContactDao.add",companyModel);
    }

    @Override
    public int getNumber(CompanyContactModel companyContactModel) {
        return GetSqlSession.getSqlSession().selectOne("com.cn.hotel.dao.ICompanyContactDao.getNumber",companyContactModel);
    }

    @Override
    public int delete(Integer temp) {
     return GetSqlSession.getSqlSession().delete("com.cn.hotel.dao.ICompanyContactDao.delete",temp);
    }

}
